package com.example.netactivity;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class ListResult extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list_result);

        EditText num = findViewById(R.id.text4);
        TextView name = findViewById(R.id.text1);  //币种
        TextView rate = findViewById(R.id.text2);  //汇率
        TextView result = findViewById(R.id.text3); //显示结果区域
        Button changebtn = findViewById(R.id.changebtn);  //点击按钮进行转化

        Bundle bundle = getIntent().getExtras();
        String num1 = bundle.getString("name");
        String num2 = bundle.getString("value");
        name.setText(num1);
        rate.setText(num2);

        changebtn.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view){
                float a = Float.parseFloat(rate.getText().toString());  //获取汇率
                float b = Float.parseFloat(num.getText().toString()); //获取输入值
                float finalresult =b/a;
                result.setText("转换后的值为"+finalresult+num1);
            }
        });

    }
}